#######################################################################################################
#######################################################################################################
use strict;

use Getopt::Long;
use LWP::Simple;
#1 enables the various debug print statements, 0 turns them off.
use constant USE_DEBUG_PRINTS   => 1;

###path config#############################################
my %CommandLineOptions;

GetOptions( \%CommandLineOptions,
            "DestinationFile=s",
            "RemoteFile=s"
          );
          
my $strDestFile   = $CommandLineOptions{"DestinationFile"};
my $strFileFeed  = $CommandLineOptions{"RemoteFile"}; 

if( length( $strDestFile ) == 0 || 
    length( $strFileFeed ) == 0 )
{
  die print( "Missing required field(s).\n".
             "Command Line Format: GetDataFile.pl --DestinationFile=\\Directory\Filename --RemoteFile=http://Address.Of.File/Filename\n".
             "--DestinationFile is the local fully qualified path where the file will be saved.\n".
             "--RemoteFile is the http address to the file we want to copy.\n" 
           );
}
elsif( USE_DEBUG_PRINTS )
{
  print "DestDir: $strDestFile\n";
  print "RemoteFile: $strFileFeed\n";
}

my $RetCode = getstore( "$strFileFeed", $strDestFile );
if( USE_DEBUG_PRINTS )
{
  if( is_success($RetCode) )
  {
    print( "Success($strFileFeed): getstore return code: $RetCode.\n");
  }
  else
  {
    print( "Error($strFileFeed): getstore return code: $RetCode.\n");   
  }
} 
